const {ccclass, property} = cc._decorator;

@ccclass
export default class pipeControl extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // 速度
    @property(cc.Integer)
    speed: number = 0
    // 移动出范围
    @property(cc.Integer)
    width: number = 0;
    @property(cc.Integer)
    pipeWidth: number = 0;

    // onLoad () {}

    start () {
    }

    update (dt) {
        let pipeArr = this.node.children;
        for(let pipe of pipeArr) {
            pipe.x -= this.speed * dt;
            if (pipe.x < (0 - this.width / 2)) {
                pipe.x += this.width * 2; 
                pipe.y = Math.random() * 200 + 430;
            }
        }
    }
}
